package controller;

import bean.UserBean;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import service.MainService;
import begin.MainView;
import tools.UtilData;
import tools.UtilMessage;

/**
 * @Author 王志康
 * @Date 2021/9/5 14:24
 * @Version 1.0.0
 */
public class RegisterController {
    @FXML
    private TextField inputNumber;

    @FXML
    private TextField inputPassword;

    @FXML
    private TextField inputName;

    @FXML
    private TextField inputPhone;


    /**
     * 监听用户注册页面点击注册事件
     *
     * @param mouseEvent 鼠标事件
     */
    @FXML
    public void registerClicked(MouseEvent mouseEvent) {
        String number = inputNumber.getText();
        String password = inputPassword.getText();
        String name = inputName.getText();
        String phone = inputPhone.getText();
        System.out.println(name);
        //异常输入数据处理
        if("".equals(number) ||"".equals(password)||"".equals(name)||"".equals(phone)){
            new UtilMessage().messageShow("请输入完整信息");
            return;
        }
        if(phone.length()!= UtilData.TELEPHONE_NUMBER_DIGITS){
            new UtilMessage().messageShow("请输入正确的手机号");
            return;
        }
        MainService.userRegister(new UserBean(number,password,name,phone));
    }
}
